{extend name="top/index" /}
{block name="main"}

    <div class="page-content-wrapper">
        <div class="page-content" style=" min-height: 700px;">
            <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
            <div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                            <h4 class="modal-title">Modal title</h4>
                        </div>
                        <div class="modal-body">
                             Widget settings form goes here
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn blue">Save changes</button>
                            <button type="button" class="btn default" data-dismiss="modal">Close</button>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <!-- /.modal -->
            <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
            <!-- BEGIN STYLE CUSTOMIZER -->
            
            <!-- END STYLE CUSTOMIZER -->
            <!-- BEGIN PAGE HEADER-->
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title">
                    权限管理 <!-- <small>view order details</small> -->
                    </h3>
                    <ul class="page-breadcrumb breadcrumb">
                        
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="{:url('index/index/index')}">
                                Home
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>
                        <li>
                            <a href="{:url('index/Power/index')}">
                                权限管理
                            </a>
                            <i class="fa fa-angle-right"></i>
                        </li>
                        
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!-- END PAGE HEADER-->
            <!-- BEGIN PAGE CONTENT-->
            <div class="content-page">
                <div class="content">
                </div>
                 <div>
                    <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Power-ID</th>
                        <th>Name</th>
                        <th>Mname</th>
                        <th>Aname</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    {volist name="data" id="vo"}
                    <tr>
                        <td>{$vo.priv_id}</td>
                        <td>{$vo.priv_name}</td>
                        <td>{$vo.mname}</td>
                        <td>{$vo.aname}</td>
                       
                        <td>
                           <button class="btn btn-danger btn del-btn" data-id="{$vo.priv_id}">删除</button>
                           <a href="{:url('edit', ['id'=>$vo['priv_id']])}" class="btn btn-warning btn">编辑</a>
                        </td>
                    </tr>
                {/volist}
                    
                    
                </tbody>
            </table>
                </div>
            {$page}
            </div>


            </div>
    </div>

           
<script>
        $(function(){
            // 设置弹框参数
        toastr.options = {
            closeButton: true,// 是否显示关闭按钮
            progressBar: true,// 实现显示计时条
            timeOut: "3000",  // 自动关闭时间
            positionClass: "toast-bottom-right" // 提示位置
            // toast-top-full-width 顶端，宽度铺满整个屏幕
            // toast-top-right  顶端右边
        };
        // 触发删除用户
        $('.del-btn').click(function (){
            var ac_id = $(this).attr('data-id');
            // console.log('删除操作,ID:', ac_id);
            if (confirm('你确定要删除吗?!')) {
            var ccc = $(this).parent().parent();
            var obj = $(this).parents('tr');
            delAjax(ac_id,obj);
        }
        });
        // AJAX删除
        function delAjax(id,obj){
            // console.log(obj);
            $.ajax({
            type: 'post',
            url: 'delete' ,
            data: {
                id:id
            },
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    // 将该条目删除掉
                    obj.remove();
                } else {
                }
            },
            error: function () {
                alert('AJAX操作失败');
            }
        });
        }
        })
    </script>
{/block}